using System;
using System.DHTML;
using Ext;
using Ext.data;
using Ext.form;

namespace SampleScripts.menu {
	public class State
	{
		public State(string _abbr, string _state)
		{
			abbr = _abbr;
			state = _state;
		}

		public string abbr;
		public string state;
	}

    public class ComboScript {

        public static void main(Dictionary args) {
			ExtClass.onReady(new AnonymousDelegate(delegate() { new ComboScript().init(); }));
        }

        public void init() {

			SimpleStore store = new SimpleStore(new SimpleStoreConfig()
				.fields(new string[] { "abbr", "state" })
				.data(States)
				.ToDictionary());

        	new ComboBox(new ComboBoxConfig()
				.store(store)
				.displayField("state")
				.typeAhead(true)
				.mode("local")
				.triggerAction("all")
				.emptyText("Select a state...")
				.selectOnFocus(true)
				.applyTo("local-states")
        	    .ToDictionary());

        	new ComboBox(new ComboBoxConfig()
				.typeAhead(true)
				.triggerAction("all")
				.transform("state")
				.width(135)
				.forceSelection(true)
        	    .ToDictionary());
		}

    	private object[] States = new object[]
    		{
    			new string[] {"AL", "Alabama" },
    			new string[] {"AK", "Alaska" },
    			new string[] {"AZ", "Arizona" },
    			new string[] {"AR", "Arkansas" },
    			new string[] {"CA", "California" },
    			new string[] {"CO", "Colorado" },
    			new string[] {"CT", "Connecticut" },
    			new string[] {"DE", "Delaware" },
    			new string[] {"DC", "District of Columbia" },
    			new string[] {"FL", "Florida" },
    			new string[] {"GA", "Georgia" },
    			new string[] {"HI", "Hawaii" },
    			new string[] {"ID", "Idaho" },
    			new string[] {"IL", "Illinois" },
    			new string[] {"IN", "Indiana" },
    			new string[] {"IA", "Iowa" },
    			new string[] {"KS", "Kansas" },
    			new string[] {"KY", "Kentucky" },
    			new string[] {"LA", "Louisiana" },
    			new string[] {"ME", "Maine" },
    			new string[] {"MD", "Maryland" },
    			new string[] {"MA", "Massachusetts" },
    			new string[] {"MI", "Michigan" },
    			new string[] {"MN", "Minnesota" },
    			new string[] {"MS", "Mississippi" },
    			new string[] {"MO", "Missouri" },
    			new string[] {"MT", "Montana" },
    			new string[] {"NE", "Nebraska" },
    			new string[] {"NV", "Nevada" },
    			new string[] {"NH", "New Hampshire" },
    			new string[] {"NJ", "New Jersey" },
    			new string[] {"NM", "New Mexico" },
    			new string[] {"NY", "New York" },
    			new string[] {"NC", "North Carolina" },
    			new string[] {"ND", "North Dakota" },
    			new string[] {"OH", "Ohio" },
    			new string[] {"OK", "Oklahoma" },
    			new string[] {"OR", "Oregon" },
    			new string[] {"PA", "Pennsylvania" },
    			new string[] {"RI", "Rhode Island" },
    			new string[] {"SC", "South Carolina" },
    			new string[] {"SD", "South Dakota" },
    			new string[] {"TN", "Tennessee" },
    			new string[] {"TX", "Texas" },
    			new string[] {"UT", "Utah" },
    			new string[] {"VT", "Vermont" },
    			new string[] {"VA", "Virginia" },
    			new string[] {"WA", "Washington" },
    			new string[] {"WV", "West Virginia" },
    			new string[] {"WI", "Wisconsin" },
    			new string[] {"WY", "Wyoming" }
    		};
    }


}
